package org.sean.framework.kafka.config;

import org.sean.framework.kafka.producer.KafkaStringProducer;
import org.sean.framework.kafka.producer.KafkaUniqueProducer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.kafka.core.KafkaTemplate;

/**
 * 自动配置 kafka
 */
@Configuration
@ConditionalOnClass(KafkaTemplate.class)
public class KafkaAutoConfiguration {

    @Bean
    @Autowired
    public KafkaStringProducer stringProducer(KafkaTemplate<Object, Object> template) {
        return new KafkaStringProducer(template);
    }

    @Bean
    @Autowired
    public KafkaUniqueProducer<Object> uniqueProducer(KafkaTemplate<Object, Object> template) {
        return new KafkaUniqueProducer<>(template);
    }

}


